const filters = {
  dateTimeFilter(val) {
    if (!val)
      return ""
    let date = new Date(val)
    let year = date.getFullYear()
    let month = date.getMonth() + 1 +""
    month = month.length>1?month:("0"+month)
    let day = date.getDate()+""
    day = day.length>1?day:("0"+day)
    let minutes = date.getMinutes()+""
    minutes = minutes.length>1?minutes:("0"+minutes)
    let hours = date.getHours()+""
    hours = hours.length>1?hours:("0"+hours)
    let seconds = date.getSeconds()+""
    seconds = seconds.length>1?seconds:("0"+seconds)
    return year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds
  },
  dateFilter(val) {
    if (!val)
      return ""
    let date = new Date(val)
    let year = date.getFullYear()
    let month = date.getMonth() + 1 +""
    month = month.length>1?month:("0"+month)
    let day = date.getDate()+""
    day = day.length>1?day:("0"+day)
    return year+"-"+month+"-"+day
  }
}

export default filters
